package com.abc.mapper;

import com.abc.entity.Xueshengjiaoshi;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface XueshengJiaoshiMapper {

    //新增教师
    @Insert("insert into xueshengjiaoshi(xueshengid,jiaoshiid) values(#{xueshengid},#{jiaoshiid})")
    int insertXueshengjiaoshi(Xueshengjiaoshi xueshengjiaoshi);
    //根据 id 查询单条记录
    @Select("select * from xueshengjiaoshi where xueshengid=#{xueshengid} and jiaoshiid = #{jiaoshiid}")
    Xueshengjiaoshi findByXueshengjiaoshiId(Xueshengjiaoshi xueshengjiaoshi);
    //查询所有的记录
    @Select("SELECT xuesheng.xingming AS xuesheng,jiaoshi.xingming AS jiaoshi FROM xueshengjiaoshi  LEFT JOIN jiaoshi ON xueshengjiaoshi.jiaoshiid = jiaoshi.id LEFT JOIN xuesheng ON xueshengjiaoshi.xueshengid = xuesheng.id")
    List<Map<String,String>> findAllXueshengjiaoshi();
    //根据教师id查询多条记录
    @Select("select js.xingming as jsxm,xs.xingming as xsxm,xs.id as xsid from jiaoshi as js  left join xueshengjiaoshi as xsjs on js.id = xsjs.jiaoshiid left join xuesheng as xs on xs.id = xsjs.xueshengid where js.id=#{jiaoshiid}")
    List<Map<String,Object>> findAllXueshengjiaoshiByJiaoshiid(String jiaoshiid);


    @Select("select js.xingming as jsxm,xs.xingming as xsxm,xs.id as xsid from jiaoshi as js  left join xueshengjiaoshi as xsjs on js.id = xsjs.jiaoshiid left join xuesheng as xs on xs.id = xsjs.xueshengid where xs.id=#{xsid}")
    List<Map<String,Object>> findAllXueshengjiaoshiXSByJiaoshiid(String xsid);


}
